package com.ht.job.task;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ht.common.core.utils.DateUtils;
import com.ht.common.core.utils.ErrorUtils;
import com.ht.job.service.ISysJobLogService;

/**
 * 清理日志
 * @author Administrator
 *
 */
@Component("cslt")
public class ClearSysLogTaskService {
	protected final Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired
	private ISysJobLogService sysJobLogService;




	/*
	 *
	 * 清理日志信息
	 */
	public void clearExpireReleaseData(Integer day){
		try {
			if(day<0){
				day=Math.abs(day);
			}
			//清理定时任务日志
			sysJobLogService.cleanJobLog();
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
			Date expireDate=DateUtils.getDateByOffSetDay(-day);
			String expireDateStr=sdf.format(expireDate);
			logger.info("清理小于[{}]的日志数据数据",expireDateStr);
		} catch (Exception e) {
			logger.error("清理小于[{}]的日志数据异常:{}",e.getMessage());
			ErrorUtils.printErr(e);
		}

	}
}
